//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.hice.demo.sbdbra.common.util;

import org.apache.commons.lang3.StringUtils;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CommonFuntions {
  public CommonFuntions() {
  }

  public static <T> boolean isEmptyObject(T obj) {
    if(obj == null) {
      return true;
    } else if(obj instanceof String) {
      String mapObje2 = (String)obj;
      return mapObje2 == null || StringUtils.isEmpty(mapObje2) || StringUtils.isBlank(StringUtils.trim(mapObje2));
    } else if(obj instanceof Collection) {
      Collection mapObje1 = (Collection)obj;
      return mapObje1 == null || mapObje1.size() <= 0 || mapObje1.isEmpty();
    } else if(obj instanceof Map) {
      Map mapObje = (Map)obj;
      return mapObje == null || mapObje.size() <= 0 || mapObje.isEmpty();
    } else {
      return !obj.getClass().isArray()?obj == null:obj == null || Array.getLength(obj) <= 0;
    }
  }

  public static <T> boolean isNotEmptyObject(T obj) {
    return !isEmptyObject(obj);
  }

  public static boolean isNumber(Object num) {
    if(num instanceof Number) {
      return true;
    } else if(num instanceof String) {
      try {
        BigDecimal e = new BigDecimal((String)num);
        e.longValue();
        return true;
      } catch (Exception var2) {
        return false;
      }
    } else {
      return false;
    }
  }

  public static boolean isNumber2(Object test) {
    try {
      (new BigDecimal(test.toString())).longValue();
      return true;
    } catch (Exception var2) {
      return false;
    }
  }

  public static boolean isNumber(Class<?> clazz) {
    return Number.class.isAssignableFrom(clazz);
  }

  public static boolean isTime(int sqlType) {
    return 92 == sqlType || 93 == sqlType;
  }

  public static boolean isDate(int sqlType) {
    return 91 == sqlType;
  }

  public static String trimBlank(String source) {
    return StringUtils.trim(source);
  }

  public static Class<?> getJavaClassInner(String type) {
    if(type.equals("String")) {
      return String.class;
    } else if(type.equals("Short")) {
      return Short.class;
    } else if(type.equals("Integer")) {
      return Integer.class;
    } else if(type.equals("Long")) {
      return Long.class;
    } else if(type.equals("Double")) {
      return Double.class;
    } else if(type.equals("Float")) {
      return Float.class;
    } else if(type.equals("Byte")) {
      return Byte.class;
    } else if(!type.equals("Char") && !type.equals("Character")) {
      if(type.equals("Boolean")) {
        return Boolean.class;
      } else if(type.equals("Date")) {
        return Date.class;
      } else if(type.equals("Time")) {
        return Time.class;
      } else if(type.equals("DateTime")) {
        return Timestamp.class;
      } else if(type.equals("Object")) {
        return Object.class;
      } else if(type.equals("short")) {
        return Short.TYPE;
      } else if(type.equals("int")) {
        return Integer.TYPE;
      } else if(type.equals("long")) {
        return Long.TYPE;
      } else if(type.equals("double")) {
        return Double.TYPE;
      } else if(type.equals("float")) {
        return Float.TYPE;
      } else if(type.equals("byte")) {
        return Byte.TYPE;
      } else if(type.equals("char")) {
        return Character.TYPE;
      } else if(type.equals("boolean")) {
        return Boolean.TYPE;
      } else {
        try {
          return loadClass(type);
        } catch (ClassNotFoundException var2) {
          throw new RuntimeException(var2);
        }
      }
    } else {
      return Character.class;
    }
  }

  public static Class<?> getJavaClass(String type) {
    int index = type.indexOf("[]");
    if(index < 0) {
      return getJavaClassInner(type);
    } else {
      String arrayString = "[";

      String baseType;
      for(baseType = type.substring(0, index); (index = type.indexOf("[]", index + 2)) >= 0; arrayString = arrayString + "[") {
        ;
      }

      Class baseClass = getJavaClassInner(baseType);

      try {
        String ex = "";
        if(!baseClass.isPrimitive()) {
          return loadClass(arrayString + "L" + baseClass.getName() + ";");
        } else {
          if(!baseClass.equals(Boolean.class) && !baseClass.equals(Boolean.TYPE)) {
            if(!baseClass.equals(Byte.class) && !baseClass.equals(Byte.TYPE)) {
              if(!baseClass.equals(Character.class) && !baseClass.equals(Character.TYPE)) {
                if(!baseClass.equals(Double.class) && !baseClass.equals(Double.TYPE)) {
                  if(!baseClass.equals(Float.class) && !baseClass.equals(Float.TYPE)) {
                    if(!baseClass.equals(Integer.class) && !baseClass.equals(Integer.TYPE)) {
                      if(!baseClass.equals(Long.class) && !baseClass.equals(Long.TYPE)) {
                        if(baseClass.equals(Short.class) || baseClass.equals(Short.TYPE)) {
                          ex = "S";
                        }
                      } else {
                        ex = "J";
                      }
                    } else {
                      ex = "I";
                    }
                  } else {
                    ex = "F";
                  }
                } else {
                  ex = "D";
                }
              } else {
                ex = "C";
              }
            } else {
              ex = "B";
            }
          } else {
            ex = "Z";
          }

          return loadClass(arrayString + ex);
        }
      } catch (ClassNotFoundException var6) {
        throw new RuntimeException(var6);
      }
    }
  }

  public static Class<?> loadClass(String name) throws ClassNotFoundException {
    Class result = null;

    try {
      result = Thread.currentThread().getContextClassLoader().loadClass(name);
    } catch (ClassNotFoundException var3) {
      ;
    }

    if(result == null) {
      result = Class.forName(name);
    }

    return result;
  }

  public static boolean isLow(char chr) {
    return chr > 90 || chr < 65;
  }

  public static boolean isUpper(char chr) {
    return chr <= 90 && chr >= 65;
  }

  public static String trimBeginUnblank(String utfStr) {
    return utfStr.charAt(0) == '\ufeff'?utfStr.substring(1):utfStr;
  }

  public static StringBuilder headToBuilder() {
    StringBuilder sb = new StringBuilder();
    byte[] hand = new byte[]{(byte)-17, (byte)-69, (byte)-65};

    try {
      sb.append(new String(hand, "UTF-8"));
    } catch (UnsupportedEncodingException var3) {
      var3.printStackTrace();
      sb = new StringBuilder();
    }

    return sb;
  }

  public static boolean checkIpAddress(String ipAddress) {
    char a = ipAddress.charAt(0);
    if(a == '\ufeff') {
      ipAddress = ipAddress.substring(1);
    }

    Pattern pattern = Pattern.compile("\\b((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\.((?!\\d\\d\\d)\\d+|1\\d\\d|2[0-4]\\d|25[0-5])\\b");
    Matcher matcher = pattern.matcher(ipAddress);
    return matcher.matches();
  }

  public static boolean isZeroNumer(Object obj) {
    return isEmptyObject(obj) || isNumber(obj) && (new BigDecimal(obj.toString())).longValue() <= 0L;
  }

  public static boolean isNotZeroNumer(Object obj) {
    return !isZeroNumer(obj);
  }

  public static Long test(String num) {
    Long rtn = null;

    try {
      rtn = Long.valueOf(Long.parseLong(num));
    } catch (Exception var3) {
      rtn = Long.valueOf(-100L);
    }

    return rtn;
  }

  public static String writerExceptionStackTrace(Throwable tabl) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    tabl.printStackTrace(pw);
    return sw.getBuffer().toString();
  }
}
